package com.kr.redeye.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

@Service
public class LoginCheckInterceptor extends HandlerInterceptorAdapter {
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		

		HttpSession session = request.getSession();
//		System.out.println("입터셉터 : " + session);
		if (session == null) {
			response.sendRedirect(request.getContextPath());
			return false;
		}else{
			if (session.getAttribute("VE_MEMBER_IDX")==null) {
				response.sendRedirect(request.getContextPath());
				return false;
			}
			
		}
		
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#finalize()
	 */
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
	}
}